#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct Stu
{
	char name[20];
	int age;
};
int cmp_int(const void* e1,const void* e2)
{
	return *((int*)e1)-*((int*)e2);
}
int cmp_structage(void* e1, void* e2)
{
	return ((struct Stu*)e1)->age - ((struct Stu*)e2)->age;
}
int cmp_structname(void* e1, void* e2)
{
	return strcmp(((struct Stu*)e1)->name, ((struct Stu*)e2)->name);
}
void test1()
{
	int arr[10] = { 1,3,5,8,9,7,6,4,2,0 };
	qsort(arr,10,sizeof(int), cmp_int);
	int i = 0;
	for (i = 0; i < 10; i++)
	{
		printf("%d ",arr[i]);
	}
}
void test2()
{
	struct Stu s[3] = { {"zhangsan",20},{"lisi",70},{"wangwu",33} };
	size_t num = sizeof(s) / sizeof(s[0]);
	qsort(s, num, sizeof(s[0]), cmp_structage);
}
void test3()
{
	struct Stu s[3] = { {"zhangsan",20},{"lisi",70},{"wangwu",33} };
	size_t num = sizeof(s) / sizeof(s[0]);
	qsort(s, num, sizeof(s[0]),cmp_structname);
}
int main()
{
	test1();
	test2();
	test3();
	return 0;
}